'use strict';
$.ajaxSetup({
    beforeSend: function (evt, request, settings) {
        request.url = 'ds-sys-web' + request.url;
    },
    dataFilter: function (result) {
        console.info(result);
        try {
            result = JSON.parse(result);
            if (result.httpCode == 401) {
                $state.go('login');
                return null;
            } else if (result.httpCode == 303) {
            } else if (result.httpCode == 200) {
            } else if (result) {
                layer.msg(result.msg, {
                    time: 2000,
                    btn: ['了解']
                });
            }
            return JSON.stringify(result);
        } catch (e) {
            return result;
        }
    },
    error: function (jqXHR, textStatus, errorThrown) {
        switch (jqXHR.status) {
            case (404):
                layer.msg('404,未找到请求的资源', {
                    time: 2000,
                    btn: ['了解']
                });
                break;
            case (405):
                $state.go('login');
                break;
        }
    }
});